package cn.itsource.upload.controller;

import cn.itsource.upload.service.IMinioService;
import cn.itsource.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/minio")
public class MinioController {
    @Autowired
    private IMinioService minioService;


    @PostMapping("/upload")
    public JsonResult upload(MultipartFile file){
        try{
            String fileName = minioService.upload(file);
            return JsonResult.success(fileName);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.error(e.getMessage());
        }
    }
}
